//
//  TiZhongPopView.m
//  markmap
//
//  Created by 甘世清 on 2024/7/18.
//

#import "TiZhongPopView.h"

@implementation TiZhongPopView

- (void)SQ_UIViewForSelfView{
    self.backgroundColor = SQColor(@"#414141");
    self.layer.cornerRadius = 25;
    
    UILabel * num4 = [[UILabel alloc]init];
    num4.text = SQNSLocalString(@"体重");
    num4.font = FONT_MEDIUM(17);
    num4.textColor = UIColor.whiteColor;
    [self addSubview:num4];
    [num4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(35);
        make.top.equalTo(self).offset(28);
    }];
    [self addSubview:self.tizhongLabel];
    [self.tizhongLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(num4);
        make.right.equalTo(self.mas_right).offset(-35);
    }];
    [self addSubview:self.ttrange2];
    [self.ttrange2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.width.mas_equalTo(SCREEN_WIDETH-32);
        make.top.equalTo(num4.mas_bottom).offset(10);
        make.height.mas_equalTo(60);
    }];
    
}
- (void)setNumber:(NSString *)number{
    _number = number;
    self.tizhongLabel.text = number;
    if (self.numberBlock) {
        self.numberBlock(self.tizhongLabel.text);
    }
    NSString * num = [number stringByReplacingOccurrencesOfString:@"KG" withString:@""];
    self.ttrange2.selectedMaximum = [num integerValue];
}

/**
 * Called when the RangeSlider values are changed
 */
-(void)rangeSlider:(TTRangeSlider *)sender didChangeSelectedMinimumValue:(float)selectedMinimum andMaximumValue:(float)selectedMaximum{
     self.tizhongLabel.text = [NSString stringWithFormat:@"%.fKG",selectedMaximum];
    if (self.numberBlock) {
        self.numberBlock(self.tizhongLabel.text);
    } 
}
- (UILabel *)tizhongLabel{
    if (!_tizhongLabel) {
        _tizhongLabel = [[UILabel alloc]init];
        _tizhongLabel.font = FONT_MEDIUM(16);
        _tizhongLabel.textColor = UIColor.whiteColor;
        _tizhongLabel.text = @"60KG";
    }
    return _tizhongLabel;
}
- (TTRangeSlider *)ttrange2{
    if (!_ttrange2) {
        _ttrange2 = [[TTRangeSlider alloc]init];
        _ttrange2.maxValue = 150;
        _ttrange2.minValue = 30;
        _ttrange2.selectedMaximum = 45;
        _ttrange2.hideLabels = YES;
        _ttrange2.step = 1;
        _ttrange2.lineHeight = 6;
        _ttrange2.disableRange = YES;
        _ttrange2.tintColor = UIColor.whiteColor;
        _ttrange2.handleDiameter = 30;
        _ttrange2.delegate = self;
        _ttrange2.tintColorBetweenHandles = UIColor.whiteColor;
      
    }
    return _ttrange2;
}
@end
